"use client"
import { Pagination } from "@heroui/pagination"
import { useRouter } from 'next/navigation';

interface IProps {
    totalPages: any
    filenName?: string
    myPage?: 1 | any
}

export const MyPagination = (props: IProps) => {
    const router = useRouter()
    return <>
        <Pagination radius="none" size="sm"
            onChange={(page: number) => {
                let url = "/search"
                if (props.filenName) {
                    url = `/search/${props.filenName}`
                }

                router.push(`${url}?page=${page}`)
            }} showControls initialPage={props.myPage} total={props.totalPages} />
    </>
}